package jsyf.oa.web.report.newAppReport;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.report.newAppReport.NewAppReportForRMFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Api(value = "全新的APP报表FOR区域经理", description = "全新的APP报表FOR区域经理")
@Controller
@RequestMapping("/newAppReportForRM")
public class NewAppReportForRMController {

    @Resource
    private NewAppReportForRMFacade newAppReportForRMFacade;

    @ResponseBody
    @RequestMapping(value = "/getForPersonalIntentCustomerList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取个人意向客户",
            notes = "获取个人意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':'','dateTime':'yyyy-MM-dd'}", dataType = "String", paramType = "body")
    public void getForPersonalIntentCustomerList(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getForPersonalIntentCustomerList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }

    @RequestMapping(value = "/getForPersonalCostByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理今日费用",
            notes = "区域经理今日费用",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':'','dateTime':'yyyy-MM-dd'}", dataType = "String", paramType = "body")
    public void getForPersonalCostByUserIdAndDateTime(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getForPersonalCostByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }

    @RequestMapping(value = "/getSignPersonByToday.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理考勤签到",
            notes = "区域经理考勤签到",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':'','dateTime':'yyyy-MM-dd'}", dataType = "String", paramType = "body")
    public void getSignPersonByToday(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getSignPersonByToday(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }

    @RequestMapping(value = "/getCustomerNumByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理客户管理",
            notes = "区域经理客户管理",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':'','dateTime':'yyyy-MM-dd'}", dataType = "String", paramType = "body")
    public void getCustomerNumByUserIdAndDateTime(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getCustomerNumByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }

    @RequestMapping(value = "/getForPersonalDayByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理面电访",
            notes = "区域经理面电访",
            httpMethod = "POST",
            response = ResponseUtils.class,
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jsonData", value = "{'userId':'','dateTime':'yyyy-MM-dd',type//0-电/1-面,status//0-AM/1-PM}", dataType = "String", paramType = "body")
    })
    public void getForPersonalDayByUserIdAndDateTime(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getForPersonalDayByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(result));
    }

    @ResponseBody
    @RequestMapping(value = "/getTodayPlanByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理今日计划",
            notes = "区域经理今日计划 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "\"{'userId':'','dateTime':'yyyy-MM-dd'}\"", dataType = "String", paramType = "body")
    public void getTodayPlanByUserIdAndDateTime(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getTodayPlanByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }

    @RequestMapping(value = "/getFirstVisitAndSignForToday.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理首次面访",
            notes = "区域经理首次面访",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':'','dateTime':'yyyy-MM-dd'}", dataType = "String", paramType = "body")
    public void getFirstVisitAndSignForToday(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getFirstVisitAndSignForToday(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }

    @ResponseBody
    @RequestMapping(value = "/getVisitCustomerByUserIdAndDateTime.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理报表拜访",
            notes = "区域经理报表拜访 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "\"{'userId':'','dateTime':'yyyy-MM-dd',type//0-电/1-面}\"", dataType = "String", paramType = "body")
    public void getVisitCustomerByUserIdAndDateTime(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getVisitCustomerByUserIdAndDateTime(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }

    @ResponseBody
    @RequestMapping(value = "/getWechatShareList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理微信转发今日数据",
            notes = "区域经理微信转发今日数据 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'20171216210041E5A8F7995E68215C12',dateTime:'2018-05-11'}", dataType = "String", paramType = "body")
    public void getWechatShareList(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getWechatShareList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }

    @RequestMapping(value = "/getSale.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理销售目标",
            notes = "区域经理销售目标",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    public void getSale(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getSaleList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }

    @RequestMapping(value = "/getAllCustomerForRM.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理所有的客户",
            notes = "区域经理所有的客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    public void getAllCustomerForRM(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getAllCustomerForRM(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }

    @RequestMapping(value = "/getNewCustomerForRM.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "区域经理新的客户",
            notes = "区域经理新的客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    public void getNewCustomerForRM(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = newAppReportForRMFacade.getNewCustomerForRM(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjTimeRespond(result));
    }


}
